package com.joy.abilityintnet.slice;

import com.joy.abilityintnet.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;

public class NewAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main_new);
        //回到MainAbilitySlice的点击事情监听
        Component newToMainButton = findComponentById(ResourceTable.Id_new_to_main);
        newToMainButton.setClickedListener(component -> terminate());
    }

    @Override
    public void onActive() {
        super.onActive();
        Intent intent = new Intent();
        //将参数传到main
        intent.setParam("key", "我从NewAbilitySlice跳回来咯");
        setResult(intent);
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}